package com.job.controller;

import com.job.common.ResponseResult;
import com.job.common.exception.CityIsNullException;
import com.job.common.exception.ProvinceIsNullException;
import com.job.pojo.City;
import com.job.pojo.Province;
import com.job.service.AreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api("区域管理接口")
@RequestMapping("/area")
public class AreaController {

    @Resource
    private AreaService areaService;

    @ApiOperation("查询省")
    @GetMapping("/province")
    public ResponseResult<List<Province>> provinceQuery() throws ProvinceIsNullException {
        return areaService.provinceQuery();
    }

    @ApiOperation("查询市")
    @GetMapping("/city")
    public ResponseResult<List<City>> cityQuery(String provinceId) throws CityIsNullException {
        return areaService.cityQuery(provinceId);
    }
}
